Skip to content

feat(deps): add pytest-xdist for parallel test execution#216

Open
ayeshakhalid192007-dev wants to merge 1 commit intonirtal85:mainfrom
ayeshakhalid192007-dev:feat/add-pytest-xdist
Open

feat(deps): add pytest-xdist for parallel test execution#216
ayeshakhalid192007-dev wants to merge 1 commit intonirtal85:mainfrom
ayeshakhalid192007-dev:feat/add-pytest-xdist

Conversation

@ayeshakhalid192007-dev
Copy link
Copy Markdown

@ayeshakhalid192007-dev ayeshakhalid192007-dev commented Apr 7, 2026

What does this PR do?

Adds pytest-xdist support to enable parallel test execution across multiple worker processes, as requested in #1.

Root Cause

Tests were running sequentially in CI, causing slow feedback loops. There was no parallelisation mechanism in place despite pytest-playwright having built-in support for pytest-xdist workers.

Changes

  • pyproject.toml: Added pytest-xdist==3.8.0 to project dependencies
  • .github/workflows/devRun.yml: Added -n 2 flag to the pytest CI command
  • pyproject.toml: Added asyncio_mode = "auto" under [tool.pytest.ini_options] to ensure async compatibility with xdist workers

Expected Impact

  • Tests run across 2 parallel workers in CI, reducing total test execution time
  • Each worker gets its own Playwright browser instance via pytest-playwright's built-in xdist support — no changes to fixtures or test files required
  • No breaking changes to existing test behaviour

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • All existing tests pass with parallel execution (pytest -n 2)
  • I have verified the CI workflow runs correctly with the -n 2 flag

Closes #1

Adds pytest-xdist==3.8.0 to project dependencies and configures CI
to run tests with -n 2 workers, enabling parallel test execution.

Closes nirtal85#1
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 7, 2026

📝 Walkthrough

Walkthrough

This pull request enables parallel test execution by adding the pytest-xdist==3.8.0 dependency and configuring the CI workflow to run tests with the -n 2 flag, allowing tests to execute concurrently on two workers during the devRun test suite execution.

Changes

Cohort / File(s) Summary
CI Workflow Configuration
.github/workflows/devRun.yml
Added -n 2 flag to pytest invocation to enable parallel test execution with xdist.
Project Dependencies
pyproject.toml
Added pytest-xdist==3.8.0 to [project].dependencies to support parallel test execution.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 Two workers hop through tests so fast,
xdist makes our suite unsurpassed,
Parallel runners, swift and free,
Coverage doubled—hooray, whee! ✨🚀

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding pytest-xdist dependency to enable parallel test execution.
Linked Issues check ✅ Passed The PR successfully implements the feature request from issue #1 by adding pytest-xdist dependency and configuring parallel execution with -n 2 flag.
Out of Scope Changes check ✅ Passed All changes are directly related to enabling parallel test execution as specified in the linked issue; no out-of-scope modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
.github/workflows/devRun.yml (1)

44-44: Make xdist worker count configurable instead of hardcoding 2.

Line 44 works, but parameterizing workers makes CI tuning easier without editing workflow code.

Proposed refactor
 env:
   FLAKINESS_PROJECT: nirtal85/Playwright-Python-Example
+  PYTEST_XDIST_WORKERS: "2"
@@
-      - name: Test with pytest
-        run: xvfb-run .venv/bin/python -m pytest -m devRun -n 2 --base-url ${{ vars.BASE_URL }}
+      - name: Test with pytest
+        run: xvfb-run .venv/bin/python -m pytest -m devRun -n "${PYTEST_XDIST_WORKERS}" --base-url ${{ vars.BASE_URL }}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/devRun.yml at line 44, Replace the hardcoded xdist worker
count "-n 2" with a configurable workflow variable: define a job- or
workflow-level env like TEST_WORKERS defaulting to "2" and update the pytest
command (the line containing "xvfb-run .venv/bin/python -m pytest -m devRun -n 2
--base-url ${{ vars.BASE_URL }}") to use "-n ${{ env.TEST_WORKERS }}" (or use
${{ vars.TEST_WORKERS }} if you prefer repo-level vars) so CI tuning can change
worker count without editing the workflow file.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In @.github/workflows/devRun.yml:
- Line 44: Replace the hardcoded xdist worker count "-n 2" with a configurable
workflow variable: define a job- or workflow-level env like TEST_WORKERS
defaulting to "2" and update the pytest command (the line containing "xvfb-run
.venv/bin/python -m pytest -m devRun -n 2 --base-url ${{ vars.BASE_URL }}") to
use "-n ${{ env.TEST_WORKERS }}" (or use ${{ vars.TEST_WORKERS }} if you prefer
repo-level vars) so CI tuning can change worker count without editing the
workflow file.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 10b687ec-f2e1-4427-bc21-28d542946c52

📥 Commits

Reviewing files that changed from the base of the PR and between 7ef4ffb and f653b22.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • .github/workflows/devRun.yml
  • pyproject.toml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parallel run with XDIST

1 participant